L<-list()
L$Topic<-read.csv("merged_topic_rhi_sat_cor.csv")
L$Dictionary<-read.csv("merged_liwc_sat_rhi_cor.csv")
nms<-c(Income="FAMILY_INCOME",SAT="RSAT_TOTAL_SCORE") #,`SAT-M`="RSAT_MATH_SCORE",`SAT-EBRW`="RSAT_EBRW")
pdf("hist_final.pdf",width=5,height=3.5)
par(mfrow=c(1,2),mar=c(3.5,3.5,.5,.5),mgp=c(2,1,0),oma=rep(.4,4))
cols<-c("red","blue")
for (i in 1:length(L)) {
  plot(NULL,xlim=c(-.5,.5),ylim=c(0,5),xlab=paste("r(x,",names(L)[i],')',sep=''),ylab="Density",main="")
  for (j in 1:length(nms)) {
    dd<-density(L[[i]][[nms[j] ]])
    lines(dd$x,dd$y,col=cols[j],lwd=2)
    z<-cbind(c(dd$x,rev(dd$x)),c(dd$y,rep(0,length(dd$y))))
    col<-col2rgb(cols[j])
    polygon(z[,1],z[,2],col=rgb(col[1],col[2],col[3],alpha=55,max=255))
  }
  legend("topright",bty='n',fill=cols,names(nms),title='x', cex = .75)
  mtext(side=3,line=0,adj=0,LETTERS[i])
}
dev.off()
